// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using AutoMapper;
using Z.SunBlog.Application.CategoryModule.BlogServer.Dto;
using Z.SunBlog.Application.PictureModule.BlogServer.Dto;
using Z.SunBlog.Core.CategoriesModule;
using Z.SunBlog.Core.PicturesModule;
using Z.SunBlog.Core.SharedDto;

namespace Z.SunBlog.Application.CategoryModule.BlogServer.MapperConfig
{
    public static class CategoryAutoMapper
    {
        /// <summary>
        /// 具体映射规则
        /// </summary>
        /// <param name="configuration"></param>
        public static void CreateMappings(IMapperConfigurationExpression configuration)
        {
            configuration.CreateMap<Categories, AddCategoryInput>().ReverseMap();
            configuration.CreateMap<Categories, UpdateCategoryInput>().ReverseMap();
            configuration.CreateMap<Categories, CategoryPageOutput>().ReverseMap();
            configuration.CreateMap<Categories, TreeSelectOutput>()
                .ForMember(dest => dest.Value, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.Label, src => src.MapFrom(c => c.Name));
        }
    }
}
